<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../library/css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../library/css/pages.css" />
		<link rel="stylesheet" href="../css/index.css" />
		<link rel="stylesheet" href="../css/page_3.css" />
		<style>
			.mui-table-view-cell select {
				width: 32%;
				text-align: center;
				margin-left: 1%;
			}
			
			.mui-table-view-cell select option {
				text-align: center;
			}
			
			.mui-table-view-cell i {
				width: 4%;
				text-align: center;
				float: left;
				display: block;
				color: #007AFF;
				font-size: 14px;
				font-weight: 700;
			}
			
			.mui-table-view-cell a {
				width: 20%;
				float: left;
				border: none;
				background-color: #3A6C92;
				color: #FFFFFF;
				font-size: 12px;
				height: 26px;
				text-align: center;
				display: block;
				line-height: 16px;
			}
			
			.mui-page .mui-table-view:last-child {
				margin-bottom: 0px;
			}
			
			.mui-page .mui-table-view:first-child {
				margin-top: 0px;
			}
			
			.mui-card {
				margin: 20px 8px;
			}
			.mui-scroll-wrapper{
				overflow: auto;
			}
			.mui-table-view-cell select{
				width: 30%;
				  direction: right;
				margin-left: 1%;
				float: left;
			}
			.mui-table-view-cell select option{
				text-align: center;
			}
			.mui-table-view-cell i{
				width: 2%;
				text-align: center;
				float: left;
				display: block;
				color: #007AFF;
				font-size: 14px;
				font-weight: 700;
			}
			.mui-table-view-cell label i{
				width: auto;
				font-size: 10px;
				font-weight: 400;
				float: none;
				display: inline-block;
			}
		</style>
	</head>
	<body>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
		</script>
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<div class="mui-card">
					<ul class="mui-table-view" id="users">
						<li class="mui-table-view-cell">
							<i style="color: #0062CC;width: 100%;height: 14px;font-size: 12px;line-height: 12px;">长按列表可以拨打电话</i>
						</li>
						<li class="mui-table-view-cell mui-media" v-for="item in data" v-gesture:tap.stop.prevent="addLink($index)" v-gesture:longtap.stop.prevent="call(item.C_linkphone)">
							<div class="mui-media-body">
								客户姓名:{{item.C_name}}
								<p class="mui-ellipsis">联系人名称:{{item.C_linkname}}</p>
								<p class="mui-ellipsis">联系人号码:{{item.C_linkphone}}</p>
							</div>
						</li>
					</ul>
				</div>
			</div>
		</div>
		</body>
		<script type="text/javascript" src="../../library/js/mui.picker.min.js"></script>
		<script type="text/javascript" src="../../js/mui.view.js"></script>
		<script type="text/javascript" src="../../js/vue.js"></script>
		<script type="text/javascript" src="../js/pageFilter.js"></script>
		<script type="text/javascript" src="../../lease/js/vue-gesture.js"></script>
		<script type="text/javascript" src="../../js/jquery.min.js" ></script>
		<script type="text/javascript" src="../../js/evalHttp.js"></script>
		<script type="text/javascript" src="../../js/Strings.js" ></script>
		<script type="text/javascript" src="../../js/util.js" ></script>
		<script>
			var app = {
				datas: {
					searData:{
						data:[]
					},
					params:{
						
					},
					isDown:false
				},
				methods: {
					_HTTP_UPDATA_LISTENER: function(isOk, data) {
						console.log(JSON.stringify(data));
						plus.nativeUI.closeWaiting();
						if(isOk) {
							plus.nativeUI.alert(data.msg);
							if(data.state==1){
								mui.back();
							}
						} else {
							plus.nativeUI.alert("网络错误，请检查您的网络！");
						}
					},
					_HTTP_SEARCH_USER:function(keyword){
						plus.nativeUI.showWaiting("搜索用户中...");
						app.datas.params.C_name = keyword;
						Xeval.Http(Xeval.Mode.HTTP_ART_GET_KEHU,app.datas.params,app.methods._HTTP_CB_GETUSERS);
					},
					_HTTP_CB_GETUSERS:function(isOk,data){
						plus.nativeUI.closeWaiting();
						mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
						mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						if(isOk){
							if(data.state==1){
								if(app.datas.isDown){
									app.datas.searData.data = data.data;
								}else{
									var arr = app.datas.searData.data;
									app.datas.searData.data = arr.concat(data.data);
								}
							}else if(data.state==2){
								plus.nativeUI.toast("没有数据");
							}
						}else{
							plus.nativeUI.alert("网络错误，请检查您的网络！");
						}
					},
					addLink:function(index){
						plus.nativeUI.showWaiting("获取客户信息中...");
						var sel = app.datas.searData.data[index];
						app.datas.params.ID = sel.ID;
						Xeval.Http(Xeval.Mode.HTTP_ART_GET_KEHU_BYID,app.datas.params,function(isOk,data){
							plus.nativeUI.closeWaiting();
							if(isOk){
								if(data.state==1){
									mui.openWindow({
										url:"../xiugai/kehuchakan.html",
										id:"kehuchakan.html",
										extras:{
											data:data
										}
									})
								}else{
									plus.nativeUI.toast(data.msg);
								}
							}else{
								plus.nativeUI.alert("网络错误,请检查您的网络！");
							}
						})
					},
					pullupRefresh:function(){
						app.datas.isDown = false;
						app.datas.params.page++;
						app.methods._HTTP_SEARCH_USER("");
					},
					pulldownRefresh:function(){
						app.datas.isDown = true;
						app.datas.params.page=1;
						app.methods._HTTP_SEARCH_USER("");
					},
					search:function(){
						var data = JSON.parse(localStorage.getItem("search"));
						localStorage.setItem("search",null);
						for(var item in data){
							var　value = data[item];
							if(value != null){
								app.datas.params[item]= value;
							}
						}
						app.methods.pulldownRefresh();
					},
					call:function(phone){
						callPhone(phone)
					}
				},
				init: function() {
					app.datas.searchVm = new Vue({
						el: "#users",
						data: app.datas.searData,
						methods: app.methods
					});
					var jsonData = JSON.parse(localStorage.getItem("art_user"));
					app.datas.params = app.utils.getToken();
					app.methods.pulldownRefresh();
				},
				utils: {
					getToken: function() {
						var jsonData = JSON.parse(localStorage.getItem("art_user"));
						var params = {
							Username:jsonData.data.T_accountnumber,
							Token:jsonData.guid,
							UserID:jsonData.data.T_UserID,
							page:1,
							rows:6
						}
						return params;
					}
				}

			}
			mui.plusReady(function() {
				Xeval.setUrl(Xeval.UrlModel.CRM); //初始化网络地址
				plus.webview.currentWebview().parent().evalJS("childReady()");
			});
			mui.init({
			pullRefresh: {
				container: '#pullrefresh',
				up: {
					callback: app.methods.pullupRefresh
				},
				down:{
					callback: app.methods.pulldownRefresh
				}
			}
		});
		</script>
</html>
